package com.craterhill.java.ccp.dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.craterhill.java.ccp.common.beans.Student;
import com.craterhill.java.ccp.dao.impl.AbstractDao;
import com.craterhill.java.ccp.dao.utils.CCPResultSetExtractor;

public interface StudentDao extends CCPDao<Student> {
	public final String FIELD_LIST = "obj.student_id, obj.department_id, obj.batch_year, obj.section_id, obj.study_type_id,"
			+ "obj.registration_number, obj.first_name, obj.middle_name, obj.last_name, obj.date_of_birth, obj.gender, obj.profile_image_path,"
			+ "obj.additional_curricular_activities, obj.rewards_achievements" + AbstractDao.MONITER_FIELDS;
	public final String FIND_ALL_STUDENT = " select " + FIELD_LIST + " from Student obj ";

	public final class StudentExtractor extends CCPResultSetExtractor<Student> {
		@Override
		protected Student extractResultSetData(ResultSet resultSet) throws SQLException {
			Student student = new Student();
			student.setStudentId(resultSet.getInt(1));
			student.setDepartmentId(resultSet.getInt(2));
			student.setBatchYear(resultSet.getInt(3));
			student.setSectionId(resultSet.getInt(4));
			student.setStudyTypeId(resultSet.getInt(5));
			student.setRegistrationNumber(resultSet.getString(6));
			student.setFirstName(resultSet.getString(7));
			student.setMiddleName(resultSet.getString(8));
			student.setLastName(resultSet.getString(9));
			student.setDateOfBirth(resultSet.getDate(10));
			student.setGender(resultSet.getInt(11));
			student.setProfileImagePath(resultSet.getString(12));
			student.setAdditionalCurricularActivities(resultSet.getString(13));
			student.setRewardsAchievements(resultSet.getString(14));
			student.setStatus(resultSet.getBoolean(15));
			student.setCreatedBy(resultSet.getInt(16));
			student.setModifiedBy(resultSet.getInt(17));
			student.setCreatedDate(resultSet.getDate(18));
			student.setModifiedDate(resultSet.getDate(19));
			return student;

		}
	}

}
